<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /* 
    需求：
        去除数组1[1,2,3,4,5]与数组2[1,3,5,7,9]中共同的元素
     */
     let array1=[1,2,3,4,5];
     let array2=[1,3,5,7,9];
     for(let i=0;i<array1.length;i++){
         //let array =array2.indexOf(array1[i]);
          /* if(array!=-1){
             array1.splice(i,1);
             array2.splice(array,1);
             i--; 
         }
   } 
     console.log(array1);
     console.log(array2); */

          for(let j=0;j<array2.length;j++){
             if(array1[i]==array2[j]){
                array1.splice(i,1);
                array2.splice(j,1);
             } 
    } 
     }
             console.log(array1);
            console.log(array2);
</script>
</html>